package com.sh.apiorder.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sh.apicommon.common.BaseResponse;
import com.sh.apicommon.common.ResultUtils;
import com.sh.apicommon.vo.OrderVO;
import com.sh.apiorder.model.dto.OrderAddRequest;
import com.sh.apiorder.model.dto.OrderQueryRequest;
import com.sh.apiorder.service.TOrderService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单
 * @author sh
 */
@RestController
@RequestMapping("/apiorder/")
public class OrderController {

    @Resource
    private TOrderService tOrderService;

    @PostMapping("/addOrder")
    public BaseResponse<OrderVO> interfaceTOrder(@RequestBody OrderAddRequest orderAddRequest, HttpServletRequest request){
        OrderVO order = tOrderService.addOrder(orderAddRequest,request);
        return ResultUtils.success(order);
    }

    /**
     * 查询订单列表
     */
    @PostMapping("/list")
    public BaseResponse<Page<OrderVO>> listPageOrder(OrderQueryRequest orderQueryRequest, HttpServletRequest request){
        Page<OrderVO> orderPage = tOrderService.listPageOrder(orderQueryRequest, request);
        return ResultUtils.success(orderPage);
    }


}
